﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Sheeps
{
    /// <summary>
    /// Dog is manually controlled by human
    /// </summary>
    public class ManualOverrideDogBehavior : DogBehaviorAlogorithm
    {
        public int X { get; set; }
        public int Y { get; set; }

        public override void UpdatePositions(GameState gameState)
        {
            Vector3 offset = new Vector3(X, Y, 0) - gameState.Dog.Position;
            if (offset.Magnitude > gameState.Dog.MaxMoveLength)
            {
                offset.Normalize();
                offset *= gameState.Dog.MaxMoveLength;
            }
            gameState.Dog.Position += offset;
            foreach (var sh in gameState.SheepList)
            {
                if ((gameState.Dog.Position - sh.Position).Magnitude < gameState.Dog.MaxBarkRange)
                {
                    sh.IsScared = true;
                }
            }
        }
    }
}
